package g4p.tests;

import g4p_controls.G4P;
import g4p_controls.GButton;
import g4p_controls.GCScheme;
import g4p_controls.GEvent;
import g4p_controls.GWinApplet;
import g4p_controls.GWinData;
import g4p_controls.GWindow;
import processing.core.PApplet;
import processing.event.MouseEvent;

public class WinCloseTest extends PApplet {



	public void setup(){
		size(480, 320, P2D);
		createGUI();
		customGUI();
		// Place your setup code here

	}

	public void draw(){
		background(230);

	}

	// Use this method to add additional statements
	// to customise the GUI controls
	public void customGUI(){
		window1.setActionOnClose(G4P.CLOSE_WINDOW);
		//  window1.setActionOnClose(G4P.EXIT_APP);
	}

	/* =========================================================
	 * ====                   WARNING                        ===
	 * =========================================================
	 * The code in this tab has been generated from the GUI form
	 * designer and care should be taken when editing this file.
	 * Only add/edit code inside the event handlers i.e. only
	 * use lines between the matching comment tags. e.g.

	 void myBtnEvents(GButton button) { //_CODE_:button1:12356:
	     // It is safe to enter your event code here  
	 } //_CODE_:button1:12356:

	 * Do not rename this tab!
	 * =========================================================
	 */

	public void button2_click1(GButton source, GEvent event) { //_CODE_:button2:913022:
		println("button2 - GButton event occured " + System.currentTimeMillis()%10000000 );
	} //_CODE_:button2:913022:

	synchronized public void win_draw1(GWinApplet appc, GWinData data) { //_CODE_:window1:531357:
		appc.background(230);
	} //_CODE_:window1:531357:

	synchronized public void winmouse(GWinApplet appc, GWinData data, MouseEvent mevent) { //_CODE_:window1:474202:
		if(mevent.getAction() == MouseEvent.CLICK){
			println("Mouse clicked " + System.currentTimeMillis()%10000000 );
			window1.close();
		}
	} //_CODE_:window1:474202:

	public void button1_click1(GButton source, GEvent event) { //_CODE_:button1:417558:
		println("Mouse clicked " + System.currentTimeMillis()%10000000 );
		window1.close();
	} //_CODE_:button1:417558:



	// Create all the GUI controls. 
	// autogenerated do not edit
	public void createGUI(){
		G4P.messagesEnabled(false);
		G4P.setGlobalColorScheme(GCScheme.BLUE_SCHEME);
		G4P.setCursor(ARROW);
		if(frame != null)
			frame.setTitle("Sketch Window");
		button2 = new GButton(this, 363, 22, 80, 30);
		button2.setText("Face text");
		button2.addEventHandler(this, "button2_click1");
		window1 = new GWindow(this, "Window title", 0, 0, 240, 120, false, JAVA2D);
		window1.addDrawHandler(this, "win_draw1");
		window1.addMouseHandler(this, "winmouse");
		button1 = new GButton(window1.papplet, 149, 77, 80, 30);
		button1.setText("Face text");
		button1.addEventHandler(this, "button1_click1");
	}

	// Variable declarations 
	// autogenerated do not edit
	GButton button2; 
	GWindow window1;
	GButton button1; 

}
